package artid.com.arttogo.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 项目名称：ArtworkArt
 * 类名称：HomeParser
 * 类描述：艺来艺往首页数据
 * 创建人：耿卫斌
 * 创建时间：2017-3-31 下午3:10:54
 */
public class HomeFragmentParser extends AppItem implements Serializable {
    private static final long serialVersionUID = 1L;
    private List<HomeFragmentAdvs> advs = new ArrayList<HomeFragmentAdvs>();//广告模块
    private List<HomeFragmentArtistInfo> artistInfo = new ArrayList<HomeFragmentArtistInfo>();//推荐艺术家

    @Override
    public void parse(JSONObject obj) {
        // TODO Auto-generated method stub
        JSONArray AdvsArr = obj.optJSONArray("data");
        if (AdvsArr != null)
            for (int i = 0; i < AdvsArr.length(); i++) {
                HomeFragmentAdvs mHomeFragmentAdvs = new HomeFragmentAdvs();
                try {
                    mHomeFragmentAdvs.setId(AdvsArr.optJSONObject(i).getString("id"));
                    mHomeFragmentAdvs.setImgurl(AdvsArr.optJSONObject(i).getString("imgurl"));
                    mHomeFragmentAdvs.setInfo(AdvsArr.optJSONObject(i).getString("info"));
                    mHomeFragmentAdvs.setLinkurl(AdvsArr.optJSONObject(i).getString("linkurl"));
                    mHomeFragmentAdvs.setTitle(AdvsArr.optJSONObject(i).getString("title"));
                    mHomeFragmentAdvs.setType(AdvsArr.optJSONObject(i).getString("type"));
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                advs.add(mHomeFragmentAdvs);
            }

//		JSONArray ArtistInfoArr = obj.optJSONArray("artistInfo");
//		for (int i = 0; i < ArtistInfoArr.length(); i++) {
//			HomeFragmentArtistInfo mHomeFragmentArtistInfo= new HomeFragmentArtistInfo();
//			try {
//				mHomeFragmentArtistInfo.setImgurl(ArtistInfoArr.optJSONObject(i).getString("imgurl"));
//				mHomeFragmentArtistInfo.setArt_num(ArtistInfoArr.optJSONObject(i).getString("art_num"));
//				mHomeFragmentArtistInfo.setFollow_num(ArtistInfoArr.optJSONObject(i).getString("follow_num"));
//				mHomeFragmentArtistInfo.setId(ArtistInfoArr.optJSONObject(i).getString("id"));
//				mHomeFragmentArtistInfo.setIs_auth(ArtistInfoArr.optJSONObject(i).getString("is_auth"));
//				mHomeFragmentArtistInfo.setRealname(ArtistInfoArr.optJSONObject(i).getString("realname"));
//				mHomeFragmentArtistInfo.setIs_follow(ArtistInfoArr.optJSONObject(i).getInt("is_follow"));
//			} catch (JSONException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
//			artistInfo.add(mHomeFragmentArtistInfo);
//		}

    }

    public List<HomeFragmentAdvs> getAdvs() {
        return advs;
    }

    public void setAdvs(List<HomeFragmentAdvs> advs) {
        this.advs = advs;
    }

    public List<HomeFragmentArtistInfo> getArtistInfo() {
        return artistInfo;
    }

    public void setArtistInfo(List<HomeFragmentArtistInfo> artistInfo) {
        this.artistInfo = artistInfo;
    }

    public HomeFragmentParser() {
        super();
    }

    public HomeFragmentParser(List<HomeFragmentAdvs> advs,
                              List<HomeFragmentArtistInfo> artistInfo) {
        super();
        this.advs = advs;
        this.artistInfo = artistInfo;
    }

    @Override
    public String toString() {
        return "HomeFragmentParser [advs=" + advs + ", artistInfo="
                + artistInfo + "]";
    }

    public class HomeFragmentAdvs implements Serializable {
        private static final long serialVersionUID = 1L;
        private String imgurl;//焦点图
        private String linkurl;//链接地址
        private String type;//类型0：使用链接地址1：鉴证机构；2：艺术家；3：艺术资讯；4：预约鉴证：5：艺术展厅：6：艺术画廊，7艺术品
        private String id;//栏目推荐ID
        private String title;//标题
        private String info;//简介

        public String getImgurl() {
            return imgurl;
        }

        public void setImgurl(String imgurl) {
            this.imgurl = imgurl;
        }

        public String getLinkurl() {
            return linkurl;
        }

        public void setLinkurl(String linkurl) {
            this.linkurl = linkurl;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getInfo() {
            return info;
        }

        public void setInfo(String info) {
            this.info = info;
        }

        public HomeFragmentAdvs() {
            super();
        }

        public HomeFragmentAdvs(String imgurl, String linkurl, String type,
                                String id, String title, String info) {
            super();
            this.imgurl = imgurl;
            this.linkurl = linkurl;
            this.type = type;
            this.id = id;
            this.title = title;
            this.info = info;
        }

        @Override
        public String toString() {
            return "HomeFragmentAdvs [imgurl=" + imgurl + ", linkurl="
                    + linkurl + ", type=" + type + ", id=" + id + ", title="
                    + title + ", info=" + info + "]";
        }
    }

    public class HomeFragmentArtistInfo implements Serializable {
        private static final long serialVersionUID = 1L;
        private String id;//艺术家ID
        private String realname;//艺术家姓名
        private String is_auth;//关注状态
        private String art_num;//艺术家总作品
        private String follow_num;//粉丝数
        private String imgurl;//艺术家头像
        private int is_follow;//艺术家认证

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getRealname() {
            return realname;
        }

        public void setRealname(String realname) {
            this.realname = realname;
        }

        public String getIs_auth() {
            return is_auth;
        }

        public void setIs_auth(String is_auth) {
            this.is_auth = is_auth;
        }

        public String getArt_num() {
            return art_num;
        }

        public void setArt_num(String art_num) {
            this.art_num = art_num;
        }

        public String getFollow_num() {
            return follow_num;
        }

        public void setFollow_num(String follow_num) {
            this.follow_num = follow_num;
        }

        public String getImgurl() {
            return imgurl;
        }

        public void setImgurl(String imgurl) {
            this.imgurl = imgurl;
        }

        public int getIs_follow() {
            return is_follow;
        }

        public void setIs_follow(int is_follow) {
            this.is_follow = is_follow;
        }

        public HomeFragmentArtistInfo() {
            super();
        }

        public HomeFragmentArtistInfo(String id, String realname,
                                      String is_auth, String art_num, String follow_num,
                                      String imgurl, int is_follow) {
            super();
            this.id = id;
            this.realname = realname;
            this.is_auth = is_auth;
            this.art_num = art_num;
            this.follow_num = follow_num;
            this.imgurl = imgurl;
            this.is_follow = is_follow;
        }

        @Override
        public String toString() {
            return "HomeFragmentArtistInfo [id=" + id + ", realname="
                    + realname + ", is_auth=" + is_auth + ", art_num="
                    + art_num + ", follow_num=" + follow_num + ", imgurl="
                    + imgurl + ", is_follow=" + is_follow + "]";
        }
    }
}
